package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.pojo.Permission;
import com.itheima.service.MenuService;
import com.itheima.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Reference
    MenuService menuService;
    //查询所有权限信息
    @RequestMapping("/findAll.do")
    public Result findAll() {
        log.debug("```````````````````````这里是菜单查询所有的查询所有方法,被访问了");
        Set<Menu> menus = menuService.findAll();
        log.debug("``````````````````````执行菜单的查询所有方法成功返回权限集合对象:"+menus);
        return new Result(true,MessageConst.ACTION_SUCCESS,menus);
    }
    @RequestMapping("/findMenusByRoleId.do")
    public Result findPermissionByRoleId(Integer id) {
        log.debug("```````````````````````这里是权限的根据角色查找对应的权限方法,被访问了");
        Set<Integer> menusIdsByRoleId = menuService.findMenusByRoleId(id);
        log.debug("``````````````````````执行权限的根据角色查找对应的权限方法成功返回权限集合对象:"+menusIdsByRoleId);
        return new Result(true,MessageConst.ACTION_SUCCESS,menusIdsByRoleId);
    }
}
